package com.tfjybj.itoo.teach.provider.controller;

import com.dmsdbj.itoo.tool.business.ItooResult;
import com.dmsdbj.itoo.tool.tenancy.TenancyContext;
import com.github.pagehelper.PageInfo;
import com.tfjybj.itoo.teach.entity.AdmTeachClassEntity;
import com.tfjybj.itoo.teach.model.AdmTeachClassModel;
import com.tfjybj.itoo.teach.model.ClassModel;
import com.tfjybj.itoo.teach.model.StudentModel;
import com.tfjybj.itoo.teach.provider.service.AdmTeachClassService;
import com.tfjybj.itoo.teach.provider.service.ClassService;
import com.tfjybj.itoo.teach.provider.service.StudentService;
import io.swagger.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * AdmTeachClassController
 * admTeachClass表
 *
 * @author 田成荣
 * @version 2.0.0
 * @since 2.0.0 2018-11-08 19:34:10
 */
@Api(tags = {"admTeachClass表接口"})
@RequestMapping(value = "/admTeachClass")
@RestController
public class AdmTeachClassController {

    private static final Logger logger = LoggerFactory.getLogger(AdmTeachClassController.class);
    private static final String ACTION_1 = "行政班查询为空或失败";
    private static final String ACTION_2 = "上课班班级信息";
    private static final String SHEETNAME = "sheetName";
    @Resource
    private AdmTeachClassService admTeachClassService;
    @Resource
    private StudentService studentService;
    @Resource
    private ClassService classService;
    //region 模板生成：基本增删改

    /**
     * 添加
     *
     * @param model AdmTeachClassModel
     * @return 添加的结果
     * @author 田成荣
     * @since 2.0.0 2018-11-08 19:34:10
     */
    @ApiOperation(value = "添加")
    @PostMapping(value = {"/create"})
    public ItooResult create(@RequestBody AdmTeachClassModel model) {
		if (StringUtils.isEmpty(model.getClassId())){
            return ItooResult.build(ItooResult.FAIL, "classId为空");
        }
		if (StringUtils.isEmpty(model.getTeachClassId())){
            return ItooResult.build(ItooResult.FAIL, "teachClassId为空");
        }
        //判断是否重复添加，根据classId和teachClassId
        Boolean flagctcount= admTeachClassService.checkByclassIdandteachClassId(model.getClassId(),model.getTeachClassId());
        if(flagctcount){
            return ItooResult.build(ItooResult.FAIL, "添加失败，本行政班已经添加");
        }
        AdmTeachClassEntity admTeachClassEntity = new AdmTeachClassEntity();
        BeanUtils.copyProperties(model, admTeachClassEntity);
        admTeachClassService.save(admTeachClassEntity);
        return ItooResult.build(ItooResult.SUCCESS, "添加成功");
    }

    /**
     * 删除
     *
     * @param id 主键id
     * @return ItooResult 是否删除成功          
     * @author 田成荣
     * @since 2.0.0 2018-11-08 19:34:10
     */
    @ApiOperation(value = "根据id删除（单个）")
    @DeleteMapping(value = {"/delete/{id}"})
    public ItooResult delete(@ApiParam(value = "主键id", required = true) @PathVariable String id) {
        admTeachClassService.removeById(id);
        return ItooResult.build(ItooResult.SUCCESS, "删除成功");
    }

    /**
     * 批量删除
     *
     * @param ids
     * @return ItooResult 批量删除是否成功结果
     * @author 田成荣
     * @since 2.0.0 2018-11-08 19:34:10
     */
    @ApiOperation(value = "根据id批量删除")
    @DeleteMapping(value = {"/deleteByIds"})
    @ApiImplicitParam(name = "ids", value = "ids", dataType = "List<String>", required = true)
    public ItooResult deleteByIds(@RequestBody List<String> ids) {
        admTeachClassService.removeByIds(ids);
        return ItooResult.build(ItooResult.SUCCESS, "批量删除成功");
    }

    /**
     * 修改
     *
     * @param model AdmTeachClassModel
     * @return 修改后的结果
     * @author 田成荣
     * @since 2.0.0 2018-11-08 19:34:10
     */
    @ApiOperation(value = "根据id修改admTeachClass")
    @PutMapping(value = {"/modify"})
    public ItooResult modify(@RequestBody AdmTeachClassModel model) {
		if (StringUtils.isEmpty(model.getClassId())){
            return ItooResult.build(ItooResult.FAIL, "classId为空");
        }
		if (StringUtils.isEmpty(model.getTeachClassId())){
            return ItooResult.build(ItooResult.FAIL, "teachClassId为空");
        }
        AdmTeachClassEntity admTeachClassEntity = new AdmTeachClassEntity();
        BeanUtils.copyProperties(model, admTeachClassEntity);
        admTeachClassService.updateById(admTeachClassEntity);
        return ItooResult.build(ItooResult.SUCCESS, "修改成功");
    }

    /**
     * 根据id查找AdmTeachClass
     *
     * @param id 主键id
     * @author 田成荣
     * @since 2.0.0 2018-11-08 19:34:10
     */
    @ApiOperation(value = "根据id查询")
    @GetMapping(value = {"/findById/{id}"})
    public ItooResult findById(@ApiParam(value = "主键id", required = true) @PathVariable String id) {
        AdmTeachClassEntity admTeachClassEntity = admTeachClassService.getById(id);
        return ItooResult.build(ItooResult.SUCCESS, "查询成功", admTeachClassEntity);
    }

    /**
     * 分页查询所有AdmTeachClass
     *
     * @param pageNo   页码
     * @param pageSize 每页条数
     * @author 田成荣
     * @since 2.0.0 2018-11-08 19:34:10
     */
    @ApiOperation(value = "分页查询所有AdmTeachClass")
    @GetMapping(value = {"/queryPageAll/{pageNo}/{pageSize}"})
    public ItooResult queryPageAll(@ApiParam(name = "pageNo",value = "页码",required = true,example = "1")@PathVariable Integer pageNo,
                                   @ApiParam(name = "pageSize",value = "页数",required = true,example = "10")@PathVariable Integer pageSize) {

        PageInfo<AdmTeachClassEntity> admTeachClasss = admTeachClassService.queryPageAll(pageNo, pageSize);
        return ItooResult.build(ItooResult.SUCCESS, "查询成功", admTeachClasss);
    }
	
	/**
     * 根据行政班id模糊查询admTeachClass
     *
     * @param classId  行政班id
     * @param pageNo   页码
     * @param pageSize 页数
     * @return 模糊查询的admTeachClass
     * @author 田成荣
     * @since 2.0.0 2018-11-08 19:34:10
     */
    @ApiOperation(value = "根据行政班id模糊查询admTeachClass", notes = "分页根据行政班id模糊查询admTeachClass")
    @GetMapping(value = "queryAdmTeachClassByLikeClassId/{pageNo}/{pageSize}")
    public ItooResult queryAdmTeachClassByLikeClassId(@RequestParam(required = false, defaultValue = "") String classId,
                                                      @ApiParam(name = "pageNo",value = "页码",required = true,example = "1") @PathVariable Integer pageNo,
                                                      @ApiParam(name = "pageSize",value = "页数",required = true,example = "10") @PathVariable Integer pageSize) {
        PageInfo<AdmTeachClassEntity> admTeachClassList = admTeachClassService.queryByLikeClassId(classId, pageNo, pageSize);
        return ItooResult.build(ItooResult.SUCCESS, "查询成功", admTeachClassList);
    }
    //endregion

    /* **********************************以下为非模板生成的内容********************************* */



    /**
     * 根据上课班ID查询所有的行政班ID
     *
     * @param teachClassId  上课班ID
     * @return 该上课班ID下所有的行政班ID
     * @author 严文文
     * @since 2.0.0 2018-11-10 10:40:28
     */

    @ApiOperation(value = "根据上课班ID查询所有的行政班ID")
    @GetMapping(value = {"/queryAdmTeachclass/{teachClassId}"})
    public ItooResult queryAdmTeachclass(@ApiParam(value = "上课班ID", required = true) @PathVariable String teachClassId) {
        if (StringUtils.isEmpty(teachClassId)){
            return ItooResult.build(ItooResult.FAIL, "teachClassId");
        }
        List<String > classIds = admTeachClassService.queryAdmTeachclass(teachClassId);
        return ItooResult.build(ItooResult.SUCCESS, "查询成功", classIds);
    }

    /**
     * 根据上课班ID查询行政班code,行政班名称,所属学院
     *
     * @param teachClassId 上课班ID
     * @return
     * @author 严文文
     * @since 2.0.0 2018-11-17 08:58:33
     */
    @ApiOperation(value = "根据上课班ID查询行政班code,行政班名称,所属学院")
    @GetMapping(value = {"/queryClassInfoByTeacherClassId/{teachClassId}/{pageNo}/{pageSize}"})
    public ItooResult queryClassInfoByTeacherClassId(
            @ApiParam(value = "上课班ID", required = true) @PathVariable String teachClassId,
            @ApiParam(name = "pageNo", value = "页码", required = true, example = "1") @PathVariable Integer pageNo,
            @ApiParam(name = "pageSize",value = "页数",required = true,example = "10") @PathVariable Integer pageSize
            ) {
        if (StringUtils.isEmpty(teachClassId)){
            return ItooResult.build(ItooResult.FAIL, "teachClassId");
        }
        PageInfo<ClassModel> classInfo = admTeachClassService.queryClassInfoByTeacherClassId(teachClassId,pageNo,pageSize);
        return ItooResult.build(ItooResult.SUCCESS, "查询成功", classInfo);
    }

    /**
     * 根据专业ID查询所属学院
     *
     * @param professionId
     * @return
     * @author 严文文
     * @since 2.0.0 2018-11-22 20:50:32
     */
    @ApiOperation(value = "根据专业ID查询所属学院")
    @GetMapping(value = {"/queryAcademyNameByProfessionId/{professionId}"})
    public ItooResult queryAcademyNameByProfessionId(@ApiParam(value = "专业ID", required = true) @PathVariable String professionId) {
        String queryAcademyNameByProfessionId = admTeachClassService.queryAcademyNameByProfessionId(professionId);
        return ItooResult.build(ItooResult.SUCCESS, "查询成功", queryAcademyNameByProfessionId);
    }


    /**
     * 根据学生ID查询班级名称
     *
     * @param studentId
     * @return
     * @author 严文文
     * @since 2.0.0 2018-11-22 21:32:09
     */
    @ApiOperation(value = "根据学生ID查询班级名称")
    @GetMapping(value = {"/queryClassNameByStudentId/{studentId}"})
    public ItooResult queryClassNameByStudentId(@ApiParam(value = "学生ID", required = true) @PathVariable String studentId) {
        String queryClassNameByStudentId = admTeachClassService.queryClassNameByStudentId(studentId);
        return ItooResult.build(ItooResult.SUCCESS, "查询成功", queryClassNameByStudentId);
    }

    /**
     * 多个行政班合成一个上课班,返回该上课班Id
     *
     * @param classIds    多个行政班Id
     * @return 上课班Id
     * @author 严文文
     * @since 2.0.0 22018-11-10 16:10:18
     */

    @ApiOperation(value = " 多个行政班合成一个上课班,返回该上课班Id")
    @PostMapping(value = {"/insertTeachClassIdByClassIds"})
    @ApiImplicitParam(name = "classIds", value = "多个行政班Id", dataType = "List<String>", required = true)
    public ItooResult insertTeachClassIdByClassIds(@RequestBody List<String> classIds) {
        if (StringUtils.isEmpty(classIds)){
            return ItooResult.build(ItooResult.FAIL, "classIds");
        }
        String teachClassId = admTeachClassService.insertTeachClassIdByClassIds(classIds);

        return ItooResult.build(ItooResult.SUCCESS, "多个行政班合成一个上课班成功",teachClassId);
    }


    /**
     * 根据班级id查询学生相关信息
     *
     * @param classId 班级ID
     * @param pageNum 页码
     * @param pageSize 每页大小
     * @return 学生信息（分页）
     * @author 严文文
     * @since 2.0.0 2018-11-11 21:38:59
     */
    @ApiOperation(value = "根据班级id查询学生相关信息", notes = "queryStudentInfoByClassId(classId, pageNum, pageSize)")
    @GetMapping(value = "/queryStudentInfoByClassId/{classId}/{pageNum}/{pageSize}")
    public ItooResult queryStudentInfoByClassId(@ApiParam( value = "班级ID", required = true) @PathVariable String classId,
                                                @ApiParam( value = "页码", required = true, example = "1") @PathVariable Integer pageNum,
                                                @ApiParam( value = "每页记录数", required = true, example = "10") @PathVariable Integer pageSize) {

        if (StringUtils.isEmpty(classId)){
            return ItooResult.build(ItooResult.FAIL, "classId");
        }
        PageInfo<StudentModel> studentModel = admTeachClassService.queryStudentInfoByClassId(classId, pageNum, pageSize);
        return ItooResult.build(ItooResult.SUCCESS, "查询成功", studentModel);
    }

    /**
     * 分页根据关键词模糊查询某上课班下的行政班名称
     *
     * @param strLike
     * @param teachClassId
     * @param pageNum
     * @param pageSize
     * @return 查询的admTeachClass
     * @author 严文文
     * @since 2.0.0 2018-11-19 21:08:06
     */
    @ApiOperation(value = "分页根据关键词模糊查询某上课班下的行政班名称")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "strLike", value = "关键词", dataType = "String"),
            @ApiImplicitParam(name = "teachClassId", value = "上课班ID", dataType = "String", required = true),
            @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "int", required = true, example = "1"),
            @ApiImplicitParam(name = "pageSize", value = "记录数", dataType = "int", required = true, example = "10" )
    })
    @GetMapping(value = "queryAdmTeachClassInfoByNameStrLike/{pageNum}/{pageSize}")
    public ItooResult queryAdmTeachClassInfoByNameStrLike(
            @RequestParam(required = false, defaultValue = "") String strLike,
            @RequestParam(required = false, defaultValue = "") String teachClassId,
            @PathVariable Integer pageNum,
            @PathVariable Integer pageSize) {
        PageInfo<ClassModel> admTeachClassModelPageInfo = admTeachClassService.queryAdmTeachClassInfoByNameStrLike(strLike,teachClassId,pageNum,pageSize);
        return ItooResult.build(ItooResult.SUCCESS, "查询成功", admTeachClassModelPageInfo);
    }

    /**
     * 分页根据关键词模糊查询某行政班下的学生姓名
     *
     * @param strLike
     * @param classId
     * @param pageNum
     * @param pageSize
     * @return
     * @author 严文文
     * @since 2.0.0 2018-11-21 11:07:30
     */
    @ApiOperation(value = "分页根据关键词模糊查询某行政班下的学生姓名")
    @GetMapping(value = "queryStudentInfoByNameStrLike/{pageNum}/{pageSize}")
    public ItooResult queryStudentInfoByNameStrLike(
            @RequestParam(required = false, defaultValue = " ") String strLike,
            @RequestParam(required = false, defaultValue = " ") String classId,
            @ApiParam(name = "pageNum", value = "页码", required = true, example = "1") @PathVariable Integer pageNum,
            @ApiParam(name = "pageSize", value = "页数", required = true, example = "10") @PathVariable Integer pageSize) {
        PageInfo<StudentModel> studentModelPageInfo  = studentService.queryByCodeNameAndClassId(strLike,classId,pageNum,pageSize);
        return ItooResult.build(ItooResult.SUCCESS, "查询成功", studentModelPageInfo);
    }


    /**
     * 分页根据学生姓名,学生code模糊查询某行政班下的学生姓名
     *
     * @param studentCode
     * @param studentName
     * @param classId
     * @param pageNum
     * @param pageSize
     * @return
     * @author 严文文
     * @since 2.0.0 2018-11-21 11:07:30
     */
    @ApiOperation(value = "分页根据学生姓名,学生code模糊查询某行政班下的学生姓名")
    @GetMapping(value = "queryStudentInfoByCodeAndNameStrLike/{pageNum}/{pageSize}")
    public ItooResult queryStudentInfoByCodeAndNameStrLike(

            @RequestParam(required = false, defaultValue = " ") String studentCode,
            @RequestParam(required = false, defaultValue = " ") String studentName,
            @RequestParam(required = false, defaultValue = " ") String classId,
            @ApiParam(name = "pageNum", value = "页码", required = true, example = "1")
            @PathVariable Integer pageNum,
            @ApiParam(name = "pageSize", value = "页数", required = true, example = "10")
            @PathVariable Integer pageSize) {
        PageInfo<StudentModel> studentModelPageInfo  = studentService.queryLikeNameAndCodeAndClassId(studentName,studentCode,classId,pageNum,pageSize);
        return ItooResult.build(ItooResult.SUCCESS, "查询成功", studentModelPageInfo);
    }


    /**
     * 分页根据关键词模糊查询某上课班下的行政班code或行政班名称
     *
     * @param classCode
     * @param className
     * @param teachClassId
     * @param pageNum
     * @param pageSize
     * @return
     * @author 严文文
     * @since 2.0.0 2018-11-19 21:08:06
     */
    @ApiOperation(value = "分页根据关键词模糊查询某上课班下的行政班code和行政班名称")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "classCode", value = "行政班code", dataType = "String"),
            @ApiImplicitParam(name = "className", value = "行政班名称", dataType = "String"),
            @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "int", required = true, example = "1"),
            @ApiImplicitParam(name = "pageSize", value = "记录数", dataType = "int", required = true, example = "10")

    })
    @GetMapping(value = "queryAdmTeachClassInfoByCodeAndNameStrLike/{pageNum}/{pageSize}")
    public ItooResult queryAdmTeachClassInfoByCodeAndNameStrLike(

            @RequestParam(required = false, defaultValue = " ") String classCode,
            @RequestParam(required = false, defaultValue = " ") String className,
            @RequestParam(required = false, defaultValue = " ") String teachClassId,
            @PathVariable Integer pageNum,
            @PathVariable Integer pageSize) {
        PageInfo<ClassModel> admTeachClassModelPageInfo = admTeachClassService.queryAdmTeachClassInfoByCodeAndNameStrLike(classCode,className,teachClassId,pageNum,pageSize);
        return ItooResult.build(ItooResult.SUCCESS, "查询成功", admTeachClassModelPageInfo);
    }


    /**
     *批量删除上课班对应的行政班信息
     *
     * @param classIds 教室Ids
     * @param teachClassId 上课班Id
     * @return 删除结果
     * @author:严文文
     * @since 2.0.0 2018-11-13 09:04:41
     */

    @ApiOperation(value = "批量删除上课班对应的行政班信息")
    @DeleteMapping(value = {"/deleteAdmTeachclass/{teachClassId}"})
    public ItooResult deleteAdmTeachclass(@ApiParam(value = "行政班Ids", required = true) @RequestBody List<String> classIds,
                                          @ApiParam(value = "上课班Id", required = true) @PathVariable String teachClassId) {

        String operator = TenancyContext.UserID.get();
        if (StringUtils.isEmpty(classIds) ) {
            return ItooResult.build(ItooResult.FAIL, "classIds");
        }
        if (StringUtils.isEmpty(operator) ) {
            return ItooResult.build(ItooResult.FAIL, "operator");
        }
        if (StringUtils.isEmpty(teachClassId) ) {
            return ItooResult.build(ItooResult.FAIL, "teachClassId");
        }
       boolean result = admTeachClassService.deleteAdmTeachclass(classIds, teachClassId, operator);
        return ItooResult.build(ItooResult.SUCCESS, "批量删除上课班对应的行政班信息成功",result);
    }

    /**
     * 单个删除上课班对应的行政班信息
     *
     * @param classId
     * @param teachClassId
     * @return
     * @author:严文文
     * @since 2.0.0 2018-12-5 14:48:38
     */
    @ApiOperation(value = "单个删除上课班对应的行政班信息")
    @DeleteMapping(value = {"/deleteSingleAdmTeachclass/{teachClassId}/{classId}"})
    public ItooResult deleteSingleAdmTeachclass(@ApiParam(value = "行政班Id", required = true) @PathVariable String classId,
                                                @ApiParam(value = "上课班Id", required = true) @PathVariable String teachClassId) {

        String operator = TenancyContext.UserID.get();
        if (StringUtils.isEmpty(classId) ) {
            return ItooResult.build(ItooResult.FAIL, "classId");
        }
        if (StringUtils.isEmpty(operator) ) {
            return ItooResult.build(ItooResult.FAIL, "operator");
        }
        if (StringUtils.isEmpty(teachClassId) ) {
            return ItooResult.build(ItooResult.FAIL, "teachClassId");
        }
        boolean result = admTeachClassService.deleteSingleAdmTeachclass(classId, teachClassId, operator);
        return ItooResult.build(ItooResult.SUCCESS, "单个删除上课班对应的行政班信息成功",result);
    }



    /**
     *上课班批量添加行政班
     *
     * @param classIds 行政班Ids
     * @param teachClassId 上课班Id
     * @return
     */
    @ApiOperation(value = "上课班批量添加行政班")
    @PostMapping(value = {"/insertAdmTeachClass/{teachClassId}"})
    public ItooResult insertAdmTeachClass(@ApiParam(value = "行政班Ids", required = true) @RequestBody List<String> classIds,
                                          @ApiParam(value = "上课班Id", required = true) @PathVariable String teachClassId) {

        String operator = TenancyContext.UserID.get();
        int result;
        if (StringUtils.isEmpty(classIds) ) {
            return ItooResult.build(ItooResult.FAIL, "classIds");
        }
        if (StringUtils.isEmpty(operator) ) {
            return ItooResult.build(ItooResult.FAIL, "operator");
        }
        if (StringUtils.isEmpty(teachClassId) ) {
            return ItooResult.build(ItooResult.FAIL, "teachClassId");
        }
        result = admTeachClassService.insertAdmTeachClass(classIds, teachClassId, operator);
        return ItooResult.build(ItooResult.SUCCESS, "上课班批量添加行政班成功",result);
    }

    /**
     * 上课班批量删除学生
     *
     * @param studentIds
     * @param teachClassId
     * @return
     */
    @ApiOperation(value = "上课班批量删除学生")
    @DeleteMapping(value = {"/deleteAdmTeachClassByStudentIds/{teachClassId}"})
    public ItooResult deleteAdmTeachClassByStudentIds(@ApiParam(value = "学生Ids", required = true) @RequestBody List<String> studentIds,
                                                      @ApiParam(value = "上课班Id", required = true) @PathVariable String teachClassId) {

        String operator = TenancyContext.UserID.get();
        int result;
        if (StringUtils.isEmpty(studentIds) ) {
            return ItooResult.build(ItooResult.FAIL, "studentIds");
        }
        if (StringUtils.isEmpty(operator) ) {
            return ItooResult.build(ItooResult.FAIL, "operator");
        }
        if (StringUtils.isEmpty(teachClassId) ) {
            return ItooResult.build(ItooResult.FAIL, "teachClassId");
        }
        result = admTeachClassService.deleteAdmTeachClassByStudentIds(studentIds, teachClassId, operator);
        return ItooResult.build(ItooResult.SUCCESS, "上课班批量添加行政班成功",result);
    }


    /**
     * 下载上课班和行政班关系表模板，批量导入使用
     *
     * @param response 响应
     * @return 下载模板是否成功
     * @author 严文文
     * @since 2.0.0 2018-11-25 17:51:30
     */
    @ApiOperation(value = "下载上课班和行政班关系表模板，批量导入使用", notes = "下载上课班和行政班关系表模板，批量导入使用")
    @GetMapping(value = {"/downLoadAdmTeachClassTemplate"})
    public ItooResult downLoadTemplate(HttpServletResponse response) {
        if (admTeachClassService.downLoadAdmTeachClassTemplate(response)) {
            return ItooResult.build(ItooResult.SUCCESS, "下载上课班和行政班关系表模板成功");
        } else {
            return ItooResult.build(ItooResult.FAIL, "下载上课班和行政班关系表模板失败");
        }
    }

    /**
     * 导出-导入失败的数据
     *
     * @param response  响应
     * @param errorListId 为成功导入的分组id
     * @return 课程信息model
     * @author 严文文
     * @since 2018-12-2 21:44:24
     */
    @ApiOperation(value = "导出-导入失败的数据")
    @GetMapping(value = "exportFile/downErrorList/{errorListId}")
    public ItooResult downErrorList(HttpServletResponse response,
                                    @ApiParam(name = "errorListId", value = "errorListId", required = true) @PathVariable String errorListId) {

        if (admTeachClassService.downErrorList(errorListId,response)){
            return ItooResult.build(ItooResult.SUCCESS,"导出成功");
        } else {
            return ItooResult.build(ItooResult.FAIL,"导出失败");
        }
    }

    /**
     * 批量导入上课班和行政班关系表
     *
     * @param multipartFile 批量导入的文件
     * @param request       请求
     * @param response      响应
     * @return ItooResult 批量导入的结果
     * @author 严文文
     * @since 2.0.0 2018-11-26 11:47:31
     */
    @ApiOperation(value = "批量导入上课班和行政班关系表", notes = "0001:部分成功；0000:成功；1111:失败")
    @PostMapping(value = {"/importAdmTeachClassByTemplate{teachClassId}"})
    public ItooResult importAdmTeachClassByTemplate(@RequestParam(value = "file") MultipartFile multipartFile,
                                                    HttpServletRequest request, HttpServletResponse response,
                                                    @ApiParam(value = "上课班Id", required = true) @PathVariable String teachClassId) {
        return admTeachClassService.importAdmTeachClassByTemplate(multipartFile, request, response,teachClassId);
    }

    /**
     * 添加行政班
     * @param model
     * @return
     * @author 严文文
     * @since 2.0.0 2018-12-3 17:20:18
     */
    @ApiOperation(value = "添加行政班")
    @PostMapping(value = "insertAdmTeachClassd")
    public ItooResult insertAdmTeachClassd(@RequestBody AdmTeachClassModel model){
        String classId= classService.queryClassesByCode(model.getClassCode()).get(0).getId();
        model.setClassId(classId);
        return this.create(model);
    }

}    
